package com.sy.sevice.impl;

import com.sy.dto.JsonResult;
import com.sy.entity.Student;
import com.sy.mapper.StudentCourseMapper;
import com.sy.sevice.StudentCourseService;
import com.sy.vo.StudentCourseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Yasuda-T
 * @version 1.0
 * @date 2020/9/14 11:08
 * @usage学生课程相关的service层
 */

@Service
public class StudentCourseServiceImpl implements StudentCourseService {
    @Autowired
    private StudentCourseMapper studentCourseMapper;

    @Override
    public JsonResult getStudentClassInfo() {
        List<Student> info = studentCourseMapper.getStudentClassInfo();
        List<StudentCourseVo> getStudentClassInfo=new ArrayList<>();
        for (Student student : info) {
            StudentCourseVo studentCourseVo = new StudentCourseVo();
            studentCourseVo.setStudentno(student.getStudentNo());
            studentCourseVo.setUsername(student.getUsername());
            studentCourseVo.setGender(student.getGender());
            studentCourseVo.setClassroomName(student.getClassroom().getName());
            getStudentClassInfo.add(studentCourseVo);
        }
        System.out.println(getStudentClassInfo);
        return JsonResult.buildSuccess(200, getStudentClassInfo);
    }
}
